/**
 * 
 */
package org.ssh2Maven.model.systemModel;

import java.util.LinkedHashSet;
import java.util.Set;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.ManyToMany;
import javax.persistence.OrderBy;
import javax.persistence.Table;

/**
 * @author guangz
 * 
 */

@Entity
@Table(name = "tb_Sys_Role")
public class SystemRole
{
	private int roleId;
	private String roleName;
	private Set<SystemFunction> functions = new LinkedHashSet<SystemFunction>();

	@Id
	@GeneratedValue(strategy=GenerationType.AUTO)
	public int getRoleId()
	{
		return roleId;
	}

	public void setRoleId(int roleId)
	{
		this.roleId = roleId;
	}

	@Column(length=20,nullable=false,unique=true)
	public String getRoleName()
	{
		return roleName;
	}

	public void setRoleName(String roleName)
	{
		this.roleName = roleName;
	}

	@ManyToMany(cascade={CascadeType.PERSIST, CascadeType.MERGE})
	@JoinTable(name="tb_Sys_Role_Function", joinColumns={@JoinColumn(name="roleId")},
					inverseJoinColumns={@JoinColumn(name="functionId")})
	@OrderBy("id")
	public Set<SystemFunction> getFunctions()
	{
		return functions;
	}

	public void setFunctions(Set<SystemFunction> functions)
	{
		this.functions = functions;
	}
}
